# 访问元素
def value(nums, i):
    if 0 <= i <= len(nums) - 1:
        print(nums[i])
    
arr = [0, 5, 2, 3, 7, 1, 6]
value(arr, 3)



# 查找元素
def find(nums,val):
    for i in range(len(nums)):
        if nums[i] == val:
            return i
    return -1

arr = [0, 5, 2, 3, 7, 1, 6]
print(find(arr, 5))



# 尾部插入元素
arr = [0, 5, 2, 3, 7, 1, 6]
val = 4
arr.append(val)
print(arr)



# 选定位置插入
arr = [0, 5, 2, 3, 7, 1, 6]
i, val = 2, 4
arr.insert(i, val)
print(arr)


# 改变元素
def change(nums, i, val):
    if 0 <= i <= len(nums) -1:
        nums[i] = val

arr = [0, 5, 2, 3, 7, 1, 6]
i, val = 2, 4
change(arr, i, val)
print(arr)


# 删除末尾元素
arr = [0, 5, 2, 3, 7, 1, 6]
arr.pop()
print(arr)


# 删除指定元素
arr = [0, 5, 2, 3, 7, 1, 6]
arr.remove(5)
print(arr)